package com.ruoyi.web.controller.market.extend;

import java.util.List;
import java.util.Map;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.ChannleUnionAddup;
import com.ruoyi.extend.service.IChannleUnionAddupService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.web.wapper.ChannleUnionAddupWapper;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 联登统计Controller
 * 
 * @author ruoyi
 * @date 2023-06-09
 */
@Controller
@RequestMapping("/extend/addup")
public class ChannleUnionAddupController extends BaseController
{
    private String prefix = "extend/addup";

    @Autowired
    private IChannleUnionAddupService channleUnionAddupService;

    @RequiresPermissions("extend:addup:view")
    @GetMapping()
    public String addup()
    {
        return prefix + "/addup";
    }

    /**
     * 查询联登统计列表
     */
    @RequiresPermissions("extend:addup:view")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ChannleUnionAddup channleUnionAddup)
    {
        startPage();
        List<Map<String, Object>> mapList = channleUnionAddupService.selectChannleUnionAddupListMap(channleUnionAddup);
        mapList = new ChannleUnionAddupWapper(mapList).wrap();
        return getDataTable(mapList);
    }

    /**
     * 导出联登统计列表
     */
    @RequiresPermissions("extend:addup:export")
    @Log(title = "联登统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ChannleUnionAddup channleUnionAddup)
    {
        List<ChannleUnionAddup> list = channleUnionAddupService.selectChannleUnionAddupList(channleUnionAddup);
        ExcelUtil<ChannleUnionAddup> util = new ExcelUtil<ChannleUnionAddup>(ChannleUnionAddup.class);
        return util.exportExcel(list, "联登统计数据");
    }

    /**
     * 新增联登统计
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存联登统计
     */
    @RequiresPermissions("extend:addup:add")
    @Log(title = "联登统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ChannleUnionAddup channleUnionAddup)
    {
        return toAjax(channleUnionAddupService.insertChannleUnionAddup(channleUnionAddup));
    }

    /**
     * 修改联登统计
     */
    @RequiresPermissions("extend:addup:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ChannleUnionAddup channleUnionAddup = channleUnionAddupService.selectChannleUnionAddupById(id);
        mmap.put("channleUnionAddup", channleUnionAddup);
        return prefix + "/edit";
    }

    /**
     * 修改保存联登统计
     */
    @RequiresPermissions("extend:addup:edit")
    @Log(title = "联登统计", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ChannleUnionAddup channleUnionAddup)
    {
        return toAjax(channleUnionAddupService.updateChannleUnionAddup(channleUnionAddup));
    }

    /**
     * 删除联登统计
     */
    @RequiresPermissions("extend:addup:remove")
    @Log(title = "联登统计", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(channleUnionAddupService.deleteChannleUnionAddupByIds(ids));
    }
}
